<template>
  <div class="app-container">
    <el-form :model="selectForm" ref="queryForm" :inline="true" label-width="120px">
      <el-form-item label="任务编号：">
        <el-input size="small"v-model="selectForm.taskCode" placeholder="请输入任务编号" clearable/>
      </el-form-item>
      <el-form-item label="计划编号：">
        <el-input size="small"  v-model="selectForm.planCode" placeholder="请输入计划编号" clearable/>
      </el-form-item>
      <el-form-item label="设备名称：">
        <el-input size="small"  v-model="selectForm.deviceName" placeholder="请输入设备名称" clearable/>
      </el-form-item>
      <el-form-item label="实际处理时间：">
        <el-date-picker
          size="small"
          v-model="dealDate"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="dateChange"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="计划处理时间：">
        <el-date-picker
          size="small"
          v-model="planDealDate"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="dateChangePlan"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="检查状态：">
        <el-select v-model="selectForm.verifyStatus" placeholder="请选择" clearable size="small">
          <el-option
            v-for="item in [{value: '1',label: '未检验'},{value: '2',label: '合格'},{value: '3',label: '不合格合格'}]"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button size="mini" type="primary" icon="el-icon-search">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="list" stripe border>
      <el-table-column align="center" type="index" label="序号" width="55"/>
      <el-table-column align="center" label="任务编号" width="150">
        <template slot-scope="scope">
          <span class="bule" @click="details(scope.row)">{{scope.row.taskCode}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="计划编号" prop="planCode"/>
      <el-table-column align="center" label="设备名称" prop="deviceName" :show-overflow-tooltip="true"/>
      <el-table-column align="center" label="设备编号" prop="deviceId" :show-overflow-tooltip="true"/>
      <el-table-column align="center" label="处理人" prop="dealUser" />
      <el-table-column label="计划处理时间" align="center" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.planDealDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际处理时间" align="center" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dealDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="结果">
        <template slot-scope="scope">
          <el-button size="mini" v-if="scope.row.result==1" type="success">合格</el-button>
          <el-button size="mini" v-if="scope.row.result==2" type="danger">不合格</el-button>
          <el-button size="mini" v-if="scope.row.result==3" type="warning">待检验</el-button>
          <el-button size="mini" v-if="scope.row.result==4" type="info">已打回</el-button>
          <el-button size="mini" v-if="scope.row.result==5" type="danger">作废</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="400" fixed="right">
        <template slot-scope="scope" v-if="scope.row.result==1">
          <el-button size="mini" type="primary" icon="el-icon-position" @click="redeploy(scope.row)">转派</el-button>
          <el-button size="mini" type="danger" icon="el-icon-delete" @click="taskDispose(scope.row,1)">作废</el-button>
          <el-button size="mini" type="danger" icon="el-icon-refresh-right" @click="taskDispose(scope.row,2)">打回</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total="total"
      :page.sync="selectForm.pageNum"
      :limit.sync="selectForm.pageSize"
      @pagination="getList"
    />
    <redeploy v-if="redeployDialog" @selectChange="redeployChange"></redeploy>
    <taskDispose v-if="typeDialog" :taskType="taskType" :taskData="taskData" @taskChange="taskDisposeChange"></taskDispose>
  </div>
</template>

<script>
  import redeploy from "./redeploy";
  import taskDispose from "./taskDispose";
  export default {
    name: "metrologicalTask.vue",
    components:{redeploy,taskDispose},
    data() {
      return {
        loading: false,//加载
        selectForm: {
          taskCode:'',//任务编号
          planCode: '',//计划编号
          deviceName: '',//设备名称
          deviceId: '',//设备编号
          dealUser:'',//处理人
          planDealDate:'',
          dealDate:'',
          result:'',
          verifyUser:'',
          verifyStatus:'',
          verifyEndDate:'',
          pageNum: 1,
          pageSize: 10,
        },//查询条件
        planDealDate:'',
        dealDate:'',
        list: [
          {
            taskCode:'CGJH2020000265',//任务编号
            planCode: 'CGJH2020000265',//计划编号
            deviceName: '设备',//设备名称
            deviceId: 'CGJH2020000265',//设备编号
            dealUser:'管理员',//处理人
            planDealDate:'2020-10-02',
            dealDate:'2020-10-02',
            result:1,
            verifyUser:'管理员',
            verifyStatus:1,
            verifyEndDate:'2020-10-02',
          },
          {
            taskCode:'CGJH2020000265',//任务编号
            planCode: 'CGJH2020000265',//计划编号
            deviceName: '设备',//设备名称
            deviceId: 'CGJH2020000265',//设备编号
            dealUser:'管理员',//处理人
            planDealDate:'2020-10-02',
            dealDate:'2020-10-02',
            result:2,
            verifyUser:'管理员',
            verifyStatus:1,
            verifyEndDate:'2020-10-02',
          },
        ],//数据
        total: 2,
        redeployDialog:false,//转派\
        typeDialog:false,//任务
        taskType:'',//任务类型
        taskData:'',//任务数据
      }
    },
    created() {
    },
    methods: {
      getList() {

      },
      //更改时间
      dateChange() {
        this.selectForm.dealDate = this.dealDate
      },
      //更改时间
      dateChangePlan() {
        this.selectForm.planDealDate = this.planDealDate
      },

      details(row){
        this.$router.push({path:'/metrological/metrologicalTaskDetail',query:{data:row}});
      },
      //转派
      redeploy(){
        this.redeployDialog=true
      },
      //成功回调
      redeployChange(data){
        this.redeployDialog=false
      },
      //任务处理
      taskDispose(row,type){
        this.taskData=row
        this.typeDialog=true
        this.taskType=type
      },
      //成功回调
      taskDisposeChange(data){
        this.typeDialog=false
      },
    }
  }
</script>

<style scoped>
  .bule {
    color: #2196F3;
    cursor: pointer
  }
</style>
